{extend name="admin@public/base" /}
{block name="styles"}
<style>
    .table-striped-new>tbody>tr:nth-of-type(4n+1) {
        background-color: #f9f9f9 !important;
    }
</style>
{/block}
{block name="main-content"}
<div class="page-content" style="padding-left:20px;padding-right:20px;">
    <div class="row maintop">
        <div class="col-xs-2 col-sm-2  margintop5">
        	{if $add eq 1}
	            <a href="{:url('admin/Help/add')}">
	                <button class="btn btn-sm btn-danger">
	                    <i class="ace-icon glyphicon glyphicon-plus bigger-110"></i>
	                    新增模板
	                </button>
	            </a>
                {/if}
        </div>
        <form class="form-search form-horizontal" action="{:url('admin/Help/index')}" method="get">
            <div class="form-group">
                    <label>模板名称 : </label>
                    <input type="text" name="name" id="name" value="{$arr['name']}" placeholder="输入模板名称关键字" class="search-query admin_sea">
                    &nbsp;&nbsp;
                    <label> 部门 : </label>
                    <select name="dept">
                        <option value="">请选择</option>
                            {foreach name="dept" item="dd"}
                                <option value="{$key}" {if condition="$arr.dept eq $key"}selected{/if}>{$dd}</option>
                            {/foreach}
                    </select>
                    <button type="submit" class="btn btn-xs btm-input btn-purple" style="margin:-5px 0 0 100px">
                        <span class="ace-icon fa fa-search icon-on-right bigger-110 ajax-search-form"></span>
                        搜索
                    </button>
            </div>
        </form>
    </div>
    <div class="tabbable">
        <div class="tab-content no-border tab-pane in active" id="pending">
                <div class="row">
                    <div class="table-responsive">
                        <table class="table table-striped-new table-bordered table-hover" id="dynamic-table">
                            <thead>
                                <tr>
                                    <th class="center" width="5%">编号</th>
                                    <th class="center">模板名称</th>
                                    <th class="center">模板说明</th>
                                    <th class="center" width="10%">所属部门</th>
                                    <th class="center" width="10%">上传日期</th>
                                    <th class="center" width="12%" style="border-right:#CCC solid 1px;">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {empty name="$data"}
                                <tr>
                                    <td colspan="6" class="center">抱歉，暂未找到符合条件的数据</td>
                                </tr>
                                {else /}
                                {foreach name="data" item="v"}
                                <tr>
                                    <td class="center">{$v.id}</td>
                                    <td class="center">{$v.name}</td>
                                    <td class="center">{$v.content}</td>
                                    <td class="center">{$v.dept_name}</td>
                                    <td class="center">{$v.create_time|date='Y-m-d',###}</td>
                                    <td class='center'>
                                        <div class="hidden-sm hidden-xs action-buttons">
                                            <a class="green down_btn_a" href="javascript:void(0)" title="下载" onclick='oDownLoad("__PUBLIC__/uploads/{$v.url}")'>
                                                <i class="ace-icon fa fa-cloud-download bigger-110"></i> 下载
                                            </a>
                                            {if condition="$del eq 1"}
                                            <a href="{:url('admin/Help/del',array('id'=>$v['id']))}" data-info="你确定要删除吗？" class="red confirm-rst-url-btn" title="删除">
                                                <i class="ace-icon fa fa-trash-o bigger-110">删除</i>
                                            </a>
                                            {/if}
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                                {notempty name="$page"}
                                <tr>
                                    <td height="50" colspan="6" align="right">{$page}</td>
                                </tr>
                                {/notempty}
                                {/empty}
                            </tbody>
                        </table>
                    </div>
                </div>
        </div>
    </div>
</div><!-- /.page-content -->
{/block}
{block name="scripts"}
<script type="text/javascript">
    ///判断浏览器类型
    function myBrowser(){
        var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
        var isOpera = userAgent.indexOf("Opera") > -1;
        if (isOpera) {
            return "Opera"
        }; //判断是否Opera浏览器
        if (userAgent.indexOf("Firefox") > -1) {
            return "FF";
        } //判断是否Firefox浏览器
        if (userAgent.indexOf("Chrome") > -1){
            return "Chrome";
        }
        if (userAgent.indexOf("Safari") > -1) {
            return "Safari";
        } //判断是否Safari浏览器
        if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
            return "IE";
        }; //判断是否IE浏览器
        if (userAgent.indexOf("Trident") > -1) {
            return "Edge";
        } //判断是否Edge浏览器
    }

    //IE浏览器图片保存本地
    function SaveAs5(imgURL)
    {
        var oPop = window.open(imgURL,"","width=1, height=1, top=5000, left=5000",false);
        for(; oPop.document.readyState != "complete"; )
        {
            if (oPop.document.readyState == "complete")break;
        }
        oPop.document.execCommand("SaveAs");
        oPop.close();
    }

    function oDownLoad(url) {
        if (myBrowser()==="IE"||myBrowser()==="Edge"){
            SaveAs5(url);
        }else{
            download(url);
        }
    }
    
    //谷歌，360极速等浏览器下载
    function download(src) {
        var $a = document.createElement('a');
        $a.setAttribute("href", src);
        $a.setAttribute("download", "");

        var evObj = document.createEvent('MouseEvents');
        evObj.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null);
        $a.dispatchEvent(evObj);
    };
</script>
{/block}
